//
//  NoteDetailViewController.m
//  product_B
//
//  Created by lanou on 16/6/3.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "NoteDetailViewController.h"

@interface NoteDetailViewController ()
@property (nonatomic,strong)UIScrollView *scrollView;
@end

@implementation NoteDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, kWidth, kHeight)];
   
    self.scrollView.pagingEnabled = YES;
    self.scrollView.bounces = YES;
    self.scrollView.showsHorizontalScrollIndicator = NO;
    self.scrollView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:_scrollView];
    
    UIImageView *imageView = [[UIImageView alloc]init];
    [imageView sd_setImageWithURL:[NSURL URLWithString:self.model.picture]];
    CGSize size ;
    NSURL *URL = [NSURL URLWithString:self.model.picture];
    NSData *data = [NSData dataWithContentsOfURL:URL];
    UIImage* image = [UIImage imageWithData:data];
    if(image)
    {
        [[SDImageCache sharedImageCache] storeImage:image recalculateFromImage:YES imageData:data forKey:URL.absoluteString toDisk:YES];
        size = image.size;
    }
    CGFloat scole = size.width/size.height;
    
    imageView.frame = CGRectMake(5, 5, kWidth-10, (kWidth-10)/scole);
    imageView.layer.cornerRadius = 5;
    imageView.layer.masksToBounds = YES;

    [self.scrollView addSubview:imageView];
     self.scrollView.contentSize = CGSizeMake(0, (kWidth-10)/scole+30);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
